<template>
  <div class="toast" v-show="isShow">
    {{message}}
  </div>
</template>

<script>
export default {
  name:'Toast',
  data(){
    return{
      message:'',
      isShow:false
    }
  },
  methods:{
    show(message,duration=2000){
      this.isShow = true;
      this.message = message;

      setTimeout(() => {
        this.isShow = false;
        this.message = ''
      },duration)
    }
  }
}
</script>

<style>
.toast{
  font-size: 16px;
  position: fixed;
  top:50%;
  left:50%;
  padding: 10px 15px;
  transform:translate(-50%,-50%);
  color: #fff;
  background: rgba(10,10,10,.5);
  border-radius: 5px;
  z-index: 999;
}
</style>